package com.xhwl.logistics.converter.mapstruct;

import com.xhwl.common.dto.cent.vehicle.feign.CreateBiVehicleAccessRecordHourFeignDTO;
import com.xhwl.common.dto.cent.vehicle.feign.CreateBiVehiclePayRecordHourFeignDTO;
import com.xhwl.logistics.bo.manipulate.VehicleInitAccessRecordStatisticsBO;
import com.xhwl.logistics.bo.manipulate.VehicleInitPayRecordStatisticsBO;
import com.xhwl.logistics.util.AboutDateUtil;
import org.mapstruct.Mapper;
import org.mapstruct.NullValueMappingStrategy;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Mapper(componentModel = "spring", nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT)
public interface VehicleInitConverter {

    default List<CreateBiVehicleAccessRecordHourFeignDTO> toCreateBiVehicleAccessRecordHourFeignDTOList(List<VehicleInitAccessRecordStatisticsBO> vehicleInitAccessRecordStatisticsBOList,
                                                                                                Integer projectId, String parkingLotName,
                                                                                                Date processTime) {
        return vehicleInitAccessRecordStatisticsBOList.stream()
                .map(vehicleInitAccessRecordStatisticsBO -> toCreateBiVehicleAccessRecordHourFeignDTO(vehicleInitAccessRecordStatisticsBO, projectId, parkingLotName, processTime))
                .collect(Collectors.toList());
    }

    default CreateBiVehicleAccessRecordHourFeignDTO toCreateBiVehicleAccessRecordHourFeignDTO(VehicleInitAccessRecordStatisticsBO vehicleInitAccessRecordStatisticsBO,
                                                                                              Integer projectId, String parkingLotName,
                                                                                              Date processTime) {
        CreateBiVehicleAccessRecordHourFeignDTO createBiVehicleAccessRecordHourFeignDTO = new CreateBiVehicleAccessRecordHourFeignDTO();
        createBiVehicleAccessRecordHourFeignDTO.setProjectId(projectId);
        createBiVehicleAccessRecordHourFeignDTO.setParkingName(parkingLotName);
        createBiVehicleAccessRecordHourFeignDTO.setIngestionTime(AboutDateUtil.hourStringToDate(vehicleInitAccessRecordStatisticsBO.getDate()));
        createBiVehicleAccessRecordHourFeignDTO.setTotal(vehicleInitAccessRecordStatisticsBO.getTotal());
        createBiVehicleAccessRecordHourFeignDTO.setIn(vehicleInitAccessRecordStatisticsBO.getIn());
        createBiVehicleAccessRecordHourFeignDTO.setOut(vehicleInitAccessRecordStatisticsBO.getOut());
        createBiVehicleAccessRecordHourFeignDTO.setProcessTime(processTime);
        return createBiVehicleAccessRecordHourFeignDTO;
    }

    default List<CreateBiVehiclePayRecordHourFeignDTO> toCreateBiVehiclePayRecordHourFeignDTOList(List<VehicleInitPayRecordStatisticsBO> vehicleInitPayRecordStatisticsBOList,
                                                                                                  Integer projectId, String parkingLotName,
                                                                                                  Date processTime) {
        return vehicleInitPayRecordStatisticsBOList.stream()
                .map(vehicleInitPayRecordStatisticsBO -> toCreateBiVehiclePayRecordHourFeignDTO(vehicleInitPayRecordStatisticsBO, projectId, parkingLotName, processTime))
                .collect(Collectors.toList());
    }

    default CreateBiVehiclePayRecordHourFeignDTO toCreateBiVehiclePayRecordHourFeignDTO(VehicleInitPayRecordStatisticsBO vehicleInitPayRecordStatisticsBO,
                                                                                        Integer projectId, String parkingLotName,
                                                                                        Date processTime) {
        CreateBiVehiclePayRecordHourFeignDTO createBiVehiclePayRecordHourFeignDTO = new CreateBiVehiclePayRecordHourFeignDTO();
        createBiVehiclePayRecordHourFeignDTO.setProjectId(projectId);
        createBiVehiclePayRecordHourFeignDTO.setParkingName(parkingLotName);
        createBiVehiclePayRecordHourFeignDTO.setIngestionTime(AboutDateUtil.hourStringToDate(vehicleInitPayRecordStatisticsBO.getDate()));
        createBiVehiclePayRecordHourFeignDTO.setTotal(vehicleInitPayRecordStatisticsBO.getTotal());

        createBiVehiclePayRecordHourFeignDTO.setWebChatPay(0);
        createBiVehiclePayRecordHourFeignDTO.setAliPay(0);
        createBiVehiclePayRecordHourFeignDTO.setOnlinePay(0);
        createBiVehiclePayRecordHourFeignDTO.setOther(0);

        createBiVehiclePayRecordHourFeignDTO.setProcessTime(processTime);
        return createBiVehiclePayRecordHourFeignDTO;
    }

}
